package xyz.liut.ee.req

import jakarta.servlet.http.HttpServletRequest


/**
 * 真实路径转换url
 *
 * @param req      请求
 * @param fileName 文件名称
 * @return url
 */
fun realPath2Url(req: HttpServletRequest, fileName: String): String {
    return req.getHost() + "/download?file=" + fileName
}


/**
 * 获取当前域
 */
fun HttpServletRequest.getHost(): String {
    val endIndex = requestURL.length - servletPath.length
    return requestURL.substring(0, endIndex)
}
